#include "sixAndtwoAlgorithm.h"

        sixAndtwoAlgorithm ::sixAndtwoAlgorithm ()
        {
         sleeptime =500;
        }
        sixAndtwoAlgorithm ::sixAndtwoAlgorithm(wxWindow * msgwin)
        {
            _win=msgwin;
        }
        sixAndtwoAlgorithm ::~sixAndtwoAlgorithm ()
        {
            //dtor
        }
        void sixAndtwoAlgorithm::setMsgWin(wxWindow * msgwin)
        {
            _win=msgwin;
        }
        wxString sixAndtwoAlgorithm ::getName()
        {
        }

         void *sixAndtwoAlgorithm ::Entry()
         {
         }

         void sixAndtwoAlgorithm ::OnExit()
         {
         }

         wxArrayString sixAndtwoAlgorithm ::tellMe(wxString term)
         {
             wxArrayString result;
             return result;
         }
         /*
            ６减２测红法就是将本期中奖红号的第６位分别与第１位及第４位相减，
            其差数，数差个位的替数、补数、减数（也含它们的邻数及同尾数）
            视为下期中奖红号的预测号。
            替数就是隔５期，如：１与６，２与７、３与８、４与９、５与０。
            补数，就是和１０数，如：１与９、２与８、３与７、４与６。
            减数就是和５数，如１与４、２与３、６与９、７与８。
            邻数，就本身 ± 数，如５的邻数６与４。
            同尾数，个位相同数，如：８与１８、２８。
            return NULL is fail;
         */
         doubleball* sixAndtwoAlgorithm::algorithm(doubleball* db)//算法处理
         {
          doubleball* result=new doubleball();
          result->ployName=db->ployName;

          std::vector<int>forecast;

            int differ6_1=db->redBall6-db->redBall1;
            int differ6_4=db->redBall6-db->redBall4;
            if(differ6_1==0)return NULL;
        //替数
            switch(differ6_1)
             {
              case 1:forecast.push_back(differ6_1+5);break;
              case 2:forecast.push_back(differ6_1+5);break;
              case 3:forecast.push_back(differ6_1+5);break;
              case 4:forecast.push_back(differ6_1+5);break;
              case 5:forecast.push_back(0);break;
             }
            switch(differ6_4)
             {
              case 1:forecast.push_back(differ6_4+5);break;
              case 2:forecast.push_back(differ6_4+5);break;
              case 3:forecast.push_back(differ6_4+5);break;
              case 4:forecast.push_back(differ6_4+5);break;
              case 5:forecast.push_back(0);break;
             }

        //补数
             switch(differ6_1)
             {
              case 1:forecast.push_back(9);break;
              case 2:forecast.push_back(8);break;
              case 3:forecast.push_back(7);break;
              case 4:forecast.push_back(6);break;
            }
                     switch(differ6_4)
             {
              case 1:forecast.push_back(9);break;
              case 2:forecast.push_back(8);break;
              case 3:forecast.push_back(7);break;
              case 4:forecast.push_back(6);break;
             }
        //减数
                     switch(differ6_1)
             {
              case 1:forecast.push_back(4);break;
              case 2:forecast.push_back(3);break;
              case 3:forecast.push_back(2);break;
              case 4:forecast.push_back(1);break;
              case 6:forecast.push_back(9);break;
              case 7:forecast.push_back(8);break;
            }
                    switch(differ6_4)
             {
              case 1:forecast.push_back(4);break;
              case 2:forecast.push_back(3);break;
              case 3:forecast.push_back(2);break;
              case 4:forecast.push_back(1);break;
              case 6:forecast.push_back(9);break;
              case 7:forecast.push_back(8);break;
            }
        //邻数
              if(differ6_1>1)
                {
                forecast.push_back(differ6_1+1);
                forecast.push_back(differ6_1-1);
                }else
                {
                forecast.push_back(differ6_1+1);
                forecast.push_back(33);
                }
              if(differ6_4>1)
                {
                forecast.push_back(differ6_4+1);
                forecast.push_back(differ6_4-1);
                }else
                {
                forecast.push_back(differ6_4+1);
                forecast.push_back(33);
                }
        //同尾数,对结果集合扫描实现
                    wxString str;
            for( int i = 0; i < forecast.size(); i++ )
            {
               int value=forecast[i]%10;
                result->forecast.Add(wxString::Format(_("%02d"),value+10));
                result->forecast.Add(wxString::Format(_("%02d"),value+20));
                if(value <4)result->forecast.Add(wxString::Format(_("%02d"),value+30));
            }
        return result;
         }
IMPLEMENT_DYNAMIC_CLASS(sixAndtwoAlgorithm, AIBase);

